﻿@using DevelopmentKit.Mvc.Menu
@{
    var menu = MenuConfigManger.Instance.Items;
    var action = this.Request.RequestContext.RouteData.Values["action"].ToString().ToLower();
    var contrller = this.Request.RequestContext.RouteData.Values["controller"].ToString().ToLower();
    var topMenu = new MenuItem();
    var currentMenu = new MenuItem();
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />  
    <link href="@Url.Content("~/Content/reset.css")" rel="stylesheet" />
   
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" /> 

    @Styles.Render("~/Content/themes/base/css")
</head>
<body>
    <div id="wrapper">
      
     <div id="header">
        <div class="logo"></div> 
    </div>
      
    <ul id="mainNav">
        @foreach (var item in menu)
        {
            var paras = new RouteValueDictionary();
            var attrs = new Dictionary<string, object>();
            if (null != item.Parameters)
            {
                foreach (var para in item.Parameters)
                {
                    paras.Add(para.Name, para.Value);
                }
            }
            if ((action == item.Action && contrller == item.Contrller) || (null != item.Items && item.Items.Any(m => action == m.Action && contrller == m.Contrller)) || (null != item.Items && item.Items.Any(m => null != m.Items && m.Items.Any(x => action == x.Action && contrller == x.Contrller))))
            {
                attrs.Add("class", "active");
                topMenu = item;
            }

            <li>@Html.ActionLink(item.Name, item.Action, item.Contrller, paras, attrs)</li>
        } 
    </ul> 
         <div id="containerHolder">
			<div id="container">
        		<div id="sidebar">
                	<ul class="sidenav">
                    	@if (null != topMenu.Items&&topMenu.Items.Any())
                        {
                            foreach (var item in topMenu.Items)
                            {
                                var paras = new RouteValueDictionary();
                                var attrs = new Dictionary<string, object>();
                                if (null != item.Parameters)
                                {
                                    foreach (var para in item.Parameters)
                                    {
                                        paras.Add(para.Name, para.Value);
                                    }
                                }
                                if ((action == item.Action && contrller == item.Contrller) || (null != item.Items && item.Items.Any(m => action == m.Action && contrller == m.Contrller)))
                                {
                                    attrs.Add("class", "active");
                                    currentMenu = item;
                                }
                                if (!item.IsHide)
                                {
                                    <li>@Html.ActionLink(item.Name, item.Action, item.Contrller, paras, attrs)</li>
                                }
                            } 
                        }
						</ul> 
                </div>    
                 
                @{
                        var currentMenuparas = new RouteValueDictionary();
                        if (null != currentMenu.Parameters)
                        {
                            foreach (var para in currentMenu.Parameters)
                            {
                                currentMenuparas.Add(para.Name, para.Value);
                            }
                        }
                        var topMenuparas = new RouteValueDictionary();
                        if (null != topMenu.Parameters)
                        {
                            foreach (var para in topMenu.Parameters)
                            {
                                topMenuparas.Add(para.Name, para.Value);
                            }
                        }
                    }
                    <h2 class="breadcrumbs">
                        @if (!string.IsNullOrEmpty(topMenu.Contrller)&&!string.IsNullOrEmpty(topMenu.Action)&&!(action == topMenu.Action && contrller == topMenu.Contrller))
                        {
                            @Html.ActionLink(topMenu.Name, topMenu.Action, topMenu.Contrller, topMenuparas, new Dictionary<string, object>()) @(new MvcHtmlString("&raquo;"))
                        }
                        @if (!string.IsNullOrEmpty(currentMenu.Contrller)&&!string.IsNullOrEmpty(currentMenu.Action)&&!(action == currentMenu.Action && contrller == currentMenu.Contrller))
                        {
                            @Html.ActionLink(currentMenu.Name, currentMenu.Action, currentMenu.Contrller, currentMenuparas, new Dictionary<string, object>())@(new MvcHtmlString("&raquo;"))
                        }
                        @ViewBag.Title
                    </h2>
                <div id="main">
                    @RenderBody()
                </div>
           
                
                <div class="clear"></div>
            </div>
           
        </div>	
      

        <div class="footer">欢迎使用系统. <a href="@Url.Action("Create", "Bug")">问题反馈?</a></div>

    @Scripts.Render("~/bundles/jquery")

    @System.Web.Optimization.Scripts.Render("~/bundles/jqueryval")

    @System.Web.Optimization.Scripts.Render("~/bundles/jqueryui")
    @RenderSection("scripts", required: false)
        <script type="text/javascript">

            $(function() {
                $("input.dataselect").live("focus", function() {
                    $(this).datepicker();
                });


            });
            
        </script>

    </div>
</body>
</html>
